import { native } from "cc";
import { sys } from "cc";

const javaClassName = "com/game/utils/ApplicationUtil";
const ocClassName = "com/game/utils/ApplicationUtil";
/**
 * 系统信息
 */
export  class AppInfo {
    /**
     * 获取设备id
     */
    public static getDevicesID():string{
        var result = "";
        //安卓 
        if(sys.os == sys.OS.ANDROID && sys.isNative){
            result = this.callJava(javaClassName, "getDeviceId", "()Ljava/lang/String;");
        }
        //ios
        else if(sys.os == sys.OS.IOS && sys.isNative)
        {

        }
        return result;
    }
    /**
     * 获取app版本号
     * @returns 
     */
    public static getAppVersion():string{
        var result = "";
        //安卓 
        if(sys.os == sys.OS.ANDROID && sys.isNative){
            result = this.callJava(javaClassName, "getAppVersion", "()Ljava/lang/String;");
        }
        //ios
        else if(sys.os == sys.OS.IOS && sys.isNative)
        {

        }
        return result;
    }

    /**
     * 调用java方法
     * @param packageName 
     * @param methodName 
     * @param methodSignature 
     * @param args 
     * @returns 
     */
    protected static callJava(packageName:string, methodName:string, methodSignature:string, ...args:any[]):any
    {
        return native.reflection.callStaticMethod(packageName, methodName, methodSignature, ...args);
    }
}